package com.wbsy.officechat.util;

import java.util.ArrayList;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;

public class ServiceOk {
	/**
	        * 用来判断服务是否运行.
	        * @param context
	        * @param className 判断的服务名字
	        * @return true 在运行 false 不在运行
	        */
	
	public static Context content;
	//本方法判断自己些的一个Service-->com.android.controlAddFunctions.PhoneService是否已经运行  
	public static boolean isWorked()  
	 {  
	  ActivityManager myManager=(ActivityManager)content.getSystemService(Context.ACTIVITY_SERVICE);  
	  ArrayList<RunningServiceInfo> runningService = (ArrayList<RunningServiceInfo>) myManager.getRunningServices(30);  
	  for(int i = 0 ; i<runningService.size();i++)  
	  {  
	   if(runningService.get(i).service.getClassName().toString().equals("com.android.controlAddFunctions.PhoneService"))  
	   {  
	    return true;  
	   }  
	  }  
	  return false;  
	 } 

}
